<?PHP // $Id: deletedfiles.php,v 1.1 2010/01/18 15:37:00 jp5987 Exp $

/// This page lists all the instances of resourcepage in a particular course
/// Replace resourcepage with the name of your module

require_once("module_resourcepage.php");

$id=required_param('course',PARAM_INT);   // course
if(!$course = get_record("course", "id", $id)) {
    error("Course ID is incorrect");
}
require_login($course->id);
if(!isediting($course->id)) {
    error('This page can only be accessed in editing mode');
}

add_to_log($course->id, "resourcepage", "view deletedfiles", "deletedfiles.php?course=$course->id");


/// Get all required strings

$strresourcepages = get_string("modulenameplural", "resourcepage");
$strresourcepage  = get_string("modulename", "resourcepage");
$strdeletedfiles  = get_string("deletedfiles", "resourcepage");

/// Print the header

if ($course->category) {
    $navigation = "<A HREF=\"../../course/view.php?id=$course->id\">$course->shortname</A> ->";
}

$navigation = build_navigation(array(array('name' => $strdeletedfiles, 'link' => '', 'type' => 'title')), $cm);
print_header("$course->shortname: $strdeletedfiles", "$course->fullname", $navigation, "", "", true, "", navmenu($course));

// ok cool now print deleted files:

global $CFG;
$folder=$CFG->dataroot.'/'.$course->id.'/moddata/resourcepage/!deleted';
$files=array();
if(is_dir($folder)) {
    
    $dir=opendir($folder);
    while (false !== ($file = readdir($dir))) {
        if($file=='.' || $file=='..') {
            continue;
        }
        $files[]=$file;       
    }
    
    closedir($dir);
} 

if(count($files)==0) {
    notice(get_string('nodeletedfiles','resourcepage'),
        $CFG->wwwroot.'/course/view.php?id='.$course->id);
} else {
    print '<div class="rp_deletedfilelist">';
    foreach($files as $file) {
        print '<div><a href="'.$CFG->wwwroot.'/file.php/'.$course->id.'/!via/resourcepage/!deleted/'.$file.
            '">'.htmlspecialchars($file).'</a></div>';
    }          
    print '</div>';
}


/// Finish the page

    print_footer($course);

?>
